{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "55f5724b",
   "metadata": {},
   "source": [
    "---------\n",
    "* 2022/09/06  \n",
    "* python课堂笔记"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e1c63671",
   "metadata": {},
   "source": [
    "# 本周学习内容  \n",
    "## 1、回顾变量  \n",
    "## 2、条件判断  \n",
    "## 3、for循环和range方法  \n",
    "## 4、random模块（伪随机数模拟）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0cd1a3ad",
   "metadata": {},
   "source": [
    "_2、条件判断_\n",
    "* if else"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "9a5799ec",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 获取星期几\n",
    "# 星期一=0\n",
    "import time\n",
    "time.localtime().tm_wday"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0fe5aeb6",
   "metadata": {},
   "source": [
    "_知识点_  \n",
    "* 1. 先创建变量，才能进行判断  \n",
    "\n",
    "* 2. if语句 观察条件判断块的位置  \n",
    "\n",
    "* 3. 按照条件块的间隙 找到归属关系"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "5d6c34eb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "开心\n"
     ]
    }
   ],
   "source": [
    "today = \"saturday\"\n",
    "condition = \"good\"\n",
    "\n",
    "if today == \"saturday\":\n",
    "    print(\"开心\")\n",
    "elif today == \"sunday\":\n",
    "    if condition == \"good\":\n",
    "        print(\"happy\")\n",
    "    else:\n",
    "        print(\"happy mini\")\n",
    "else:\n",
    "    print(\"study\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "41f5bebb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "今天没有python课\n"
     ]
    }
   ],
   "source": [
    "# 判断当前是一周中的星期几，如果是星期二，看下现在几点了，是python课ing么？然后打印Python课表\n",
    "\n",
    "import time\n",
    "\n",
    "today = time.localtime().tm_wday #星期\n",
    "time_hour = time.localtime().tm_hour #小时\n",
    "time_min = time.localtime().tm_min #分钟\n",
    "\n",
    "h = [13,14,15]\n",
    "\n",
    "if today == \"1\":\n",
    "    print(\"有课\")\n",
    "    \n",
    "elif time_hour == 12 and time_min > 50:\n",
    "        print(\"python课ing\")\n",
    "elif time_hour in h:\n",
    "        print(\"python课ing\")\n",
    "elif time_hour == 16 and time_min <50:\n",
    "        print(\"python课ing\")\n",
    "else:\n",
    "    print(\"今天没有python课\")\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "8cffa986",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "没课\n"
     ]
    }
   ],
   "source": [
    "# 判断当前是一周中的星期几，如果是星期二，看下现在几点了，是python课ing么？然后打印Python课表\n",
    "\n",
    "import time\n",
    "\n",
    "today = time.localtime().tm_wday\n",
    "time_hour = time.localtime().tm_hour\n",
    "time_min = time.localtime().tm_min\n",
    "\n",
    "h = [13,14,15]\n",
    "\n",
    "if today != \"1\":\n",
    "    print(\"没课\")\n",
    "    \n",
    "elif time_hour == 12 and time_min > 50:\n",
    "        print(\"python课ing\")\n",
    "elif time_hour in h:\n",
    "        print(\"python课ing\")\n",
    "elif time_hour == 16 and time_min <50:\n",
    "        print(\"python课ing\")\n",
    "else:\n",
    "    print(\"今天有python课\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "46f106b9",
   "metadata": {},
   "source": [
    "_3、for循环和range方法_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "99c89bd0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "# i=item 循环遍历\n",
    "\n",
    "for i in [1,2,3]:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "1323bd1f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "52\n",
      "1\n",
      "2\n",
      "3\n",
      "55\n"
     ]
    }
   ],
   "source": [
    "import datetime\n",
    "print(time.localtime().tm_sec)\n",
    "for i in [1,2,3]:\n",
    "    print(i)\n",
    "time.sleep(3)   # time.sleep(）暂停 \n",
    "print(time.localtime().tm_sec)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "001cefb0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "H\n",
      "i\n",
      "!\n"
     ]
    }
   ],
   "source": [
    "for ch in \"Hi!\":\n",
    "    print(ch)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "7484c6f1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Head First Rocks!\n",
      "Head First Rocks!\n",
      "Head First Rocks!\n",
      "Head First Rocks!\n",
      "Head First Rocks!\n"
     ]
    }
   ],
   "source": [
    "for num in range(5):\n",
    "    print(\"Head First Rocks!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "a2f848df",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n"
     ]
    }
   ],
   "source": [
    "for num in range(6):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "eeecbc26",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n"
     ]
    }
   ],
   "source": [
    "#  range()自动生成想要的数值，可以控制for循环的次数，一个值，就是从0开始几个数\n",
    "for num in range(6):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "b45b2d3b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "# range()自动生成想要的数值，可以控制for循环的次数，两个值，从小数（2）开始，大数-小数的个数（5-2）\n",
    "for num in range(2,5):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "c337e51d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "3\n",
      "6\n",
      "9\n"
     ]
    }
   ],
   "source": [
    "# 三个值，第三个值决定step步长\n",
    "for num in range(0,10,3):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "70c072c1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "https://www.nfu.edu.cn/ztb/index0.htm\n",
      "https://www.nfu.edu.cn/ztb/index1.htm\n",
      "https://www.nfu.edu.cn/ztb/index2.htm\n",
      "https://www.nfu.edu.cn/ztb/index3.htm\n",
      "https://www.nfu.edu.cn/ztb/index4.htm\n",
      "https://www.nfu.edu.cn/ztb/index5.htm\n",
      "https://www.nfu.edu.cn/ztb/index6.htm\n",
      "https://www.nfu.edu.cn/ztb/index7.htm\n",
      "https://www.nfu.edu.cn/ztb/index8.htm\n",
      "https://www.nfu.edu.cn/ztb/index9.htm\n",
      "https://www.nfu.edu.cn/ztb/index10.htm\n",
      "https://www.nfu.edu.cn/ztb/index11.htm\n",
      "https://www.nfu.edu.cn/ztb/index12.htm\n",
      "https://www.nfu.edu.cn/ztb/index13.htm\n",
      "https://www.nfu.edu.cn/ztb/index14.htm\n",
      "https://www.nfu.edu.cn/ztb/index15.htm\n",
      "https://www.nfu.edu.cn/ztb/index16.htm\n",
      "https://www.nfu.edu.cn/ztb/index17.htm\n",
      "https://www.nfu.edu.cn/ztb/index18.htm\n",
      "https://www.nfu.edu.cn/ztb/index19.htm\n",
      "https://www.nfu.edu.cn/ztb/index20.htm\n",
      "https://www.nfu.edu.cn/ztb/index21.htm\n",
      "https://www.nfu.edu.cn/ztb/index22.htm\n",
      "https://www.nfu.edu.cn/ztb/index23.htm\n",
      "https://www.nfu.edu.cn/ztb/index24.htm\n",
      "https://www.nfu.edu.cn/ztb/index25.htm\n",
      "https://www.nfu.edu.cn/ztb/index26.htm\n"
     ]
    }
   ],
   "source": [
    "# for循环遍历案例： 某学校新闻网站数据URL队列获取\n",
    "\n",
    "# 中大南方-招投标-https://www.nfu.edu.cn/ztb/index.htm\n",
    "\n",
    "中大南方 = \"https://www.nfu.edu.cn/ztb/index.htm\"\n",
    "for page in range(27):\n",
    "    print(\"https://www.nfu.edu.cn/ztb/index\" + str(page) + \".htm\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "10f003f4",
   "metadata": {},
   "source": [
    "_4、random模块_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "f4eb7533",
   "metadata": {},
   "outputs": [],
   "source": [
    "import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "29308e37",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.42872362746410786"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# random.random方法：取（0-1之间的随机数）\n",
    "random.random()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "92ee66bd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "7"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 规定范围\n",
    "random.randint(1,8)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "f1ede9c2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "9\n",
      "2\n",
      "6\n",
      "4\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "# 在1-9中随机取5个数\n",
    "\n",
    "for i in range(5):\n",
    "    print(random.randint(1,9))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "cf168b78",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'中明'"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 随机选名字\n",
    "random.choice([\"小明\",\"中明\",\"大明\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "id": "85ee3f54",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3\n",
      "奇\n",
      "4\n",
      "偶\n",
      "6\n",
      "偶\n",
      "7\n",
      "奇\n",
      "8\n",
      "偶\n"
     ]
    }
   ],
   "source": [
    "import datetime\n",
    "import time\n",
    "import random\n",
    "\n",
    "odds = [  1,  3,  5,  7,  9, 11,13,15,17,19,\n",
    "              21,23,25,27,29,31,33,35,37,39,\n",
    "              41,43,45,47,49,51,53,55,57,59 ]\n",
    "\n",
    "for i in range(5):\n",
    "    right_this_second = datetime.datetime.today().second\n",
    "\n",
    "    if right_this_second in odds:\n",
    "        print(right_this_second)\n",
    "        print(\"奇\")\n",
    "    else:\n",
    "        print(right_this_second)\n",
    "        print(\"偶\")\n",
    "    time.sleep(random.randint(1,3))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3e150ed5",
   "metadata": {},
   "source": [
    "### 课本43实践"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "id": "f58aaf9b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99 botters 在啤酒墙上\n",
      "99 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "98 在啤酒墙上\n",
      "98 botters 在啤酒墙上\n",
      "98 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "97 在啤酒墙上\n",
      "97 botters 在啤酒墙上\n",
      "97 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "96 在啤酒墙上\n",
      "96 botters 在啤酒墙上\n",
      "96 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "95 在啤酒墙上\n",
      "95 botters 在啤酒墙上\n",
      "95 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "94 在啤酒墙上\n",
      "94 botters 在啤酒墙上\n",
      "94 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "93 在啤酒墙上\n",
      "93 botters 在啤酒墙上\n",
      "93 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "92 在啤酒墙上\n",
      "92 botters 在啤酒墙上\n",
      "92 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "91 在啤酒墙上\n",
      "91 botters 在啤酒墙上\n",
      "91 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "90 在啤酒墙上\n",
      "90 botters 在啤酒墙上\n",
      "90 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "89 在啤酒墙上\n",
      "89 botters 在啤酒墙上\n",
      "89 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "88 在啤酒墙上\n",
      "88 botters 在啤酒墙上\n",
      "88 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "87 在啤酒墙上\n",
      "87 botters 在啤酒墙上\n",
      "87 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "86 在啤酒墙上\n",
      "86 botters 在啤酒墙上\n",
      "86 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "85 在啤酒墙上\n",
      "85 botters 在啤酒墙上\n",
      "85 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "84 在啤酒墙上\n",
      "84 botters 在啤酒墙上\n",
      "84 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "83 在啤酒墙上\n",
      "83 botters 在啤酒墙上\n",
      "83 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "82 在啤酒墙上\n",
      "82 botters 在啤酒墙上\n",
      "82 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "81 在啤酒墙上\n",
      "81 botters 在啤酒墙上\n",
      "81 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "80 在啤酒墙上\n",
      "80 botters 在啤酒墙上\n",
      "80 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "79 在啤酒墙上\n",
      "79 botters 在啤酒墙上\n",
      "79 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "78 在啤酒墙上\n",
      "78 botters 在啤酒墙上\n",
      "78 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "77 在啤酒墙上\n",
      "77 botters 在啤酒墙上\n",
      "77 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "76 在啤酒墙上\n",
      "76 botters 在啤酒墙上\n",
      "76 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "75 在啤酒墙上\n",
      "75 botters 在啤酒墙上\n",
      "75 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "74 在啤酒墙上\n",
      "74 botters 在啤酒墙上\n",
      "74 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "73 在啤酒墙上\n",
      "73 botters 在啤酒墙上\n",
      "73 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "72 在啤酒墙上\n",
      "72 botters 在啤酒墙上\n",
      "72 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "71 在啤酒墙上\n",
      "71 botters 在啤酒墙上\n",
      "71 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "70 在啤酒墙上\n",
      "70 botters 在啤酒墙上\n",
      "70 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "69 在啤酒墙上\n",
      "69 botters 在啤酒墙上\n",
      "69 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "68 在啤酒墙上\n",
      "68 botters 在啤酒墙上\n",
      "68 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "67 在啤酒墙上\n",
      "67 botters 在啤酒墙上\n",
      "67 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "66 在啤酒墙上\n",
      "66 botters 在啤酒墙上\n",
      "66 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "65 在啤酒墙上\n",
      "65 botters 在啤酒墙上\n",
      "65 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "64 在啤酒墙上\n",
      "64 botters 在啤酒墙上\n",
      "64 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "63 在啤酒墙上\n",
      "63 botters 在啤酒墙上\n",
      "63 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "62 在啤酒墙上\n",
      "62 botters 在啤酒墙上\n",
      "62 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "61 在啤酒墙上\n",
      "61 botters 在啤酒墙上\n",
      "61 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "60 在啤酒墙上\n",
      "60 botters 在啤酒墙上\n",
      "60 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "59 在啤酒墙上\n",
      "59 botters 在啤酒墙上\n",
      "59 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "58 在啤酒墙上\n",
      "58 botters 在啤酒墙上\n",
      "58 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "57 在啤酒墙上\n",
      "57 botters 在啤酒墙上\n",
      "57 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "56 在啤酒墙上\n",
      "56 botters 在啤酒墙上\n",
      "56 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "55 在啤酒墙上\n",
      "55 botters 在啤酒墙上\n",
      "55 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "54 在啤酒墙上\n",
      "54 botters 在啤酒墙上\n",
      "54 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "53 在啤酒墙上\n",
      "53 botters 在啤酒墙上\n",
      "53 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "52 在啤酒墙上\n",
      "52 botters 在啤酒墙上\n",
      "52 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "51 在啤酒墙上\n",
      "51 botters 在啤酒墙上\n",
      "51 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "50 在啤酒墙上\n",
      "50 botters 在啤酒墙上\n",
      "50 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "49 在啤酒墙上\n",
      "49 botters 在啤酒墙上\n",
      "49 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "48 在啤酒墙上\n",
      "48 botters 在啤酒墙上\n",
      "48 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "47 在啤酒墙上\n",
      "47 botters 在啤酒墙上\n",
      "47 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "46 在啤酒墙上\n",
      "46 botters 在啤酒墙上\n",
      "46 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "45 在啤酒墙上\n",
      "45 botters 在啤酒墙上\n",
      "45 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "44 在啤酒墙上\n",
      "44 botters 在啤酒墙上\n",
      "44 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "43 在啤酒墙上\n",
      "43 botters 在啤酒墙上\n",
      "43 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "42 在啤酒墙上\n",
      "42 botters 在啤酒墙上\n",
      "42 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "41 在啤酒墙上\n",
      "41 botters 在啤酒墙上\n",
      "41 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "40 在啤酒墙上\n",
      "40 botters 在啤酒墙上\n",
      "40 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "39 在啤酒墙上\n",
      "39 botters 在啤酒墙上\n",
      "39 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "38 在啤酒墙上\n",
      "38 botters 在啤酒墙上\n",
      "38 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "37 在啤酒墙上\n",
      "37 botters 在啤酒墙上\n",
      "37 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "36 在啤酒墙上\n",
      "36 botters 在啤酒墙上\n",
      "36 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "35 在啤酒墙上\n",
      "35 botters 在啤酒墙上\n",
      "35 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "34 在啤酒墙上\n",
      "34 botters 在啤酒墙上\n",
      "34 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "33 在啤酒墙上\n",
      "33 botters 在啤酒墙上\n",
      "33 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "32 在啤酒墙上\n",
      "32 botters 在啤酒墙上\n",
      "32 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "31 在啤酒墙上\n",
      "31 botters 在啤酒墙上\n",
      "31 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "30 在啤酒墙上\n",
      "30 botters 在啤酒墙上\n",
      "30 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "29 在啤酒墙上\n",
      "29 botters 在啤酒墙上\n",
      "29 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "28 在啤酒墙上\n",
      "28 botters 在啤酒墙上\n",
      "28 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "27 在啤酒墙上\n",
      "27 botters 在啤酒墙上\n",
      "27 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "26 在啤酒墙上\n",
      "26 botters 在啤酒墙上\n",
      "26 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "25 在啤酒墙上\n",
      "25 botters 在啤酒墙上\n",
      "25 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "24 在啤酒墙上\n",
      "24 botters 在啤酒墙上\n",
      "24 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "23 在啤酒墙上\n",
      "23 botters 在啤酒墙上\n",
      "23 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "22 在啤酒墙上\n",
      "22 botters 在啤酒墙上\n",
      "22 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "21 在啤酒墙上\n",
      "21 botters 在啤酒墙上\n",
      "21 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "20 在啤酒墙上\n",
      "20 botters 在啤酒墙上\n",
      "20 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "19 在啤酒墙上\n",
      "19 botters 在啤酒墙上\n",
      "19 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "18 在啤酒墙上\n",
      "18 botters 在啤酒墙上\n",
      "18 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "17 在啤酒墙上\n",
      "17 botters 在啤酒墙上\n",
      "17 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "16 在啤酒墙上\n",
      "16 botters 在啤酒墙上\n",
      "16 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "15 在啤酒墙上\n",
      "15 botters 在啤酒墙上\n",
      "15 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "14 在啤酒墙上\n",
      "14 botters 在啤酒墙上\n",
      "14 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "13 在啤酒墙上\n",
      "13 botters 在啤酒墙上\n",
      "13 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "12 在啤酒墙上\n",
      "12 botters 在啤酒墙上\n",
      "12 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "11 在啤酒墙上\n",
      "11 botters 在啤酒墙上\n",
      "11 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "10 在啤酒墙上\n",
      "10 botters 在啤酒墙上\n",
      "10 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "9 在啤酒墙上\n",
      "9 botters 在啤酒墙上\n",
      "9 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "8 在啤酒墙上\n",
      "8 botters 在啤酒墙上\n",
      "8 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "7 在啤酒墙上\n",
      "7 botters 在啤酒墙上\n",
      "7 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "6 在啤酒墙上\n",
      "6 botters 在啤酒墙上\n",
      "6 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "5 在啤酒墙上\n",
      "5 botters 在啤酒墙上\n",
      "5 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "4 在啤酒墙上\n",
      "4 botters 在啤酒墙上\n",
      "4 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "3 在啤酒墙上\n",
      "3 botters 在啤酒墙上\n",
      "3 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "2 在啤酒墙上\n",
      "2 botters 在啤酒墙上\n",
      "2 botters 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "1 在啤酒墙上\n",
      "1 bottle 在啤酒墙上\n",
      "1 bottle 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "没有更多的啤酒在啤酒墙上了\n",
      "1 在啤酒墙上\n",
      "\n"
     ]
    }
   ],
   "source": [
    "word = \"botters\"\n",
    "\n",
    "# 共99瓶啤酒，每次拿一瓶（-1）\n",
    "for beer_num in range(99, 0, -1):\n",
    "    \n",
    "    print(beer_num, word, \"在啤酒墙上\")\n",
    "    \n",
    "    print(beer_num, word, \"啤酒\")\n",
    "    \n",
    "    print(\"拿下一瓶\")\n",
    "    \n",
    "    print(\"传递它\")\n",
    "    \n",
    "    if beer_num == 1:\n",
    "        \n",
    "        print(\"没有更多的啤酒在啤酒墙上了\")\n",
    "        \n",
    "    else:\n",
    "        new_num = beer_num - 1\n",
    "        \n",
    "    if new_num == 1:\n",
    "        \n",
    "        word = \"bottle\"\n",
    "        \n",
    "    print(new_num, \"在啤酒墙上\")\n",
    "    \n",
    "print()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b596d4a5",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
